package com.itheima.health.dao;

import com.itheima.health.pojo.entity.Order;
import com.itheima.health.pojo.vo.OrderFindByIdVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;
import java.time.LocalDate;

@Mapper
public interface OrderDao {

    /**
     * 向订单表插入数据
     * @param order
     */
    @Options(keyProperty = "id", useGeneratedKeys = true)
    @Insert("insert into t_order values (null, #{memberId}, #{orderDate}, #{orderType}, #{orderStatus}, #{setmealId})")
    void insert(Order order);

    Integer findOrderCountByDate(String date);

    Integer findOrderCountAfterDate(String date);

    Integer findVisitsCountByDate(String date);

    Integer findVisitsCountAfterDate(String date);

    List<Map> findHotSetmeal();
    /**
     *
     * @param id
     * @return
     */
    Map selectById(String id);


    @Select("select count(*) from t_order where member_id = #{memberId} and setmeal_id = #{setmealId} and orderDate = #{orderDate}")
    Integer selectCountByMemberAndSetmeal(Integer memberId, String setmealId, LocalDate orderDate);
    /**
     * 根据id查询订单
     * @param id
     * @return
     */
    OrderFindByIdVO findById(String id);
}
